//
//  PopFiltrateView.m
//  YTwallet
//
//  Created by ZhangLin on 2019/3/8.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "PopFiltrateView.h"
#import <Masonry.h>
@implementation PopFiltrateView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupViews];
    }
    return self;
}

-(void)setupViews{
    self.backgroundColor = [UIColor whiteColor];
    

    self.resetBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.resetBtn.backgroundColor = [UIColor colorWithRed:233 / 255.0 green:236 / 255.0 blue:255 / 255.0 alpha:1];
    [self.resetBtn setTitle:@"重置" forState:(UIControlStateNormal)];
    [self.resetBtn setTitleColor:[UIColor colorWithRed:91 / 255.0 green:113 / 255.0 blue:255 / 255.0 alpha:1] forState:(UIControlStateNormal)];
    self.resetBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [self addSubview:self.resetBtn];
    [self.resetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(44);
        make.width.equalTo(self).multipliedBy(0.5);
    }];
    
    self.confirmBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.confirmBtn.backgroundColor = [UIColor colorWithRed:91 / 255.0 green:113 / 255.0 blue:255 / 255.0 alpha:1];
    [self.confirmBtn setTitle:@"确定" forState:(UIControlStateNormal)];
    [self.confirmBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    self.confirmBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [self addSubview:self.confirmBtn];
    [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(44);
        make.width.equalTo(self).multipliedBy(0.5);
    }];
    
    self.lineView = [[UIView alloc] init];
    self.lineView.backgroundColor = [UIColor colorWithRed:229 / 255.0 green:229 / 255.0 blue:229 / 255.0 alpha:1];
    [self addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(1);
        make.top.equalTo(self);
    }];
    
    self.moenyLab = [[UILabel alloc] init];
    self.moenyLab.text = @"金额";
    self.moenyLab.font = [UIFont boldSystemFontOfSize:16];
    self.moenyLab.textColor = [UIColor colorWithRed:51 / 255.0 green:51 / 255.0 blue:51 / 255.0 alpha:1];
    [self addSubview:self.moenyLab];
    [self.moenyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.equalTo(self.lineView.mas_bottom).offset(20);
    }];
    
    self.minimumAmountTf = [[UITextField alloc] init];
    self.minimumAmountTf.keyboardType = UIKeyboardTypePhonePad;
    self.minimumAmountTf.placeholder = @"  ￥ 最低金额";
    self.minimumAmountTf.backgroundColor = [UIColor colorWithRed:248 / 255.0 green:248 / 255.0 blue:248 / 255.0 alpha:1];
    self.minimumAmountTf.layer.cornerRadius = 18;
    //把textField的光标向后移
    //移动的像素
    NSInteger m = 15;
    UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, m, 40)];
    self.minimumAmountTf.leftView = paddingView;
    self.minimumAmountTf.leftViewMode = UITextFieldViewModeAlways;
    [self addSubview:self.minimumAmountTf];
    
    
    
    self.maxAmountTf = [[UITextField alloc] init];
    self.maxAmountTf.keyboardType = UIKeyboardTypePhonePad;
    self.maxAmountTf.placeholder = @"  ￥ 最高金额";
    self.maxAmountTf.backgroundColor = [UIColor colorWithRed:248 / 255.0 green:248 / 255.0 blue:248 / 255.0 alpha:1];
    self.maxAmountTf.layer.cornerRadius = 18;
    //把textField的光标向后移
    UIView *paddingView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, m, 40)];
    self.maxAmountTf.leftView = paddingView1;
    self.maxAmountTf.leftViewMode = UITextFieldViewModeAlways;
    [self addSubview:self.maxAmountTf];
    
    NSMutableArray *amountArray = [NSMutableArray array];
    [amountArray addObject:self.minimumAmountTf];
    [amountArray addObject:self.maxAmountTf];
    
    [amountArray mas_distributeViewsAlongAxis:(MASAxisTypeHorizontal) withFixedSpacing:25 leadSpacing:15 tailSpacing:15];
    [amountArray mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.moenyLab.mas_bottom).offset(10);
        make.height.mas_equalTo(36);
    }];
    
    
    
    self.toAmountView = [[UIView alloc] init];
    self.toAmountView .alpha = 1.0;
    self.toAmountView.layer.borderColor = [UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1.0].CGColor;
    self.toAmountView.layer.borderWidth = 1;
    self.toAmountView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    self.toAmountView.layer.cornerRadius = 1;
    [self addSubview:self.toAmountView];
    [self.toAmountView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.centerY.equalTo(self.maxAmountTf);
        make.height.mas_equalTo(2);
        make.width.mas_equalTo(10);
    }];
    

    self.timeLab = [[UILabel alloc] init];
    self.timeLab.text = @"时间";
    self.timeLab.font = [UIFont boldSystemFontOfSize:16];
    self.timeLab.textColor = [UIColor colorWithRed:51 / 255.0 green:51 / 255.0 blue:51 / 255.0 alpha:1];
    [self addSubview:self.timeLab];
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.equalTo(self.minimumAmountTf.mas_bottom).offset(44);
    }];

    
    self.dayBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.dayBtn setTitle:@"按日" forState:(UIControlStateNormal)];
    [self.dayBtn setTitleColor:[UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1] forState:(UIControlStateNormal)];
    [self.dayBtn setTitleColor:[UIColor colorWithRed:91 / 255.0 green:113 / 255.0 blue:255 / 255.0 alpha:1] forState:(UIControlStateSelected)];
    self.dayBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.dayBtn];
    [self.dayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.equalTo(self.timeLab);
    }];
    
    self.verticalLineView = [[UIView alloc] init];
    self.verticalLineView.backgroundColor = [UIColor colorWithRed:229 / 255.0 green:229 / 255.0 blue:229 / 255.0 alpha:1];
    [self addSubview:self.verticalLineView];
    [self.verticalLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.dayBtn.mas_left).offset(-15);
        make.height.mas_equalTo(14);
        make.centerY.equalTo(self.dayBtn);
        make.width.mas_equalTo(2);
    }];

    self.monthBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.monthBtn setTitle:@"按月" forState:(UIControlStateNormal)];
    [self.monthBtn setTitleColor:[UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1] forState:(UIControlStateNormal)];
    [self.monthBtn setTitleColor:[UIColor colorWithRed:91 / 255.0 green:113 / 255.0 blue:255 / 255.0 alpha:1] forState:(UIControlStateSelected)];
    self.monthBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.monthBtn];
    [self.monthBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.verticalLineView.mas_left).offset(-15);
        make.centerY.equalTo(self.timeLab);
    }];
    
    
    self.selectDayView = [[UIView alloc] init];
    [self addSubview:self.selectDayView];
    [self.selectDayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.equalTo(self.timeLab.mas_bottom).offset(30);
        make.height.mas_equalTo(44);
    }];
    
    self.zhiLab = [[UILabel alloc] init];
    self.zhiLab.text = @"至";
    self.zhiLab.textColor = [UIColor colorWithRed:153.0f/255.0f green:153.0f/255.0f blue:153.0f/255.0f alpha:1.0f];
    self.zhiLab.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14.0f];
    [self.selectDayView addSubview:self.zhiLab];
    [self.zhiLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.centerX.equalTo(self);
    }];
    
    
    
    self.dayLineView = [[UIView alloc] init];
    self.dayLineView.layer.backgroundColor = [[UIColor colorWithRed:204.0f/255.0f green:204.0f/255.0f blue:204.0f/255.0f alpha:1.0f] CGColor];
    [self.selectDayView addSubview:self.dayLineView];
    [self.dayLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(40);
        make.right.equalTo(self.zhiLab.mas_left).offset(-15);
        make.top.equalTo(self.zhiLab.mas_bottom).offset(5);
        make.height.mas_equalTo(1);
    }];
    
    self.daybeginValueLab = [[UILabel alloc] init];
    self.daybeginValueLab.text = @"开始时间";
    self.daybeginValueLab.textColor = [UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f];
    self.daybeginValueLab.font = [UIFont systemFontOfSize:14.0f];
    [self.selectDayView addSubview:self.daybeginValueLab];
    [self.daybeginValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.dayLineView);
        make.centerY.equalTo(self.zhiLab);
    }];
    
    
    
    
    self.dayEndLineView = [[UIView alloc] init];
    self.dayEndLineView.layer.backgroundColor = [[UIColor colorWithRed:204.0f/255.0f green:204.0f/255.0f blue:204.0f/255.0f alpha:1.0f] CGColor];
    [self.selectDayView addSubview:self.dayEndLineView];
    [self.dayEndLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.zhiLab.mas_right).offset(15);
        make.right.equalTo(self).offset(-40);
        make.bottom.equalTo(self.dayLineView);
        make.height.mas_equalTo(1);
    }];
    
    
    self.dayEndValueLab = [[UILabel alloc] init];
    self.dayEndValueLab.text = @"结束时间";
    self.dayEndValueLab.textColor = [UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f];
    self.dayEndValueLab.font = [UIFont systemFontOfSize:14.0f];
    [self.selectDayView addSubview:self.dayEndValueLab];
    [self.dayEndValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.dayEndLineView);
        make.centerY.equalTo(self.zhiLab);
    }];
    
    
    
    
    self.datepickerView = [[UIView alloc] init];
    [self addSubview:self.datepickerView];
    [self.datepickerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.equalTo(self.dayEndLineView.mas_bottom);
        make.bottom.equalTo(self.resetBtn.mas_top).offset(-20);
    }];
    
    self.selectMonthView = [[UIView alloc] init];
    [self addSubview:self.selectMonthView];
    [self.selectMonthView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.equalTo(self.timeLab.mas_bottom).offset(30);
        make.height.mas_equalTo(44);
    }];
    
    self.monthLineView = [[UIView alloc] init];
    [self.selectMonthView addSubview:self.monthLineView];
    self.monthLineView.backgroundColor = [UIColor colorWithRed:204.0f/255.0f green:204.0f/255.0f blue:204.0f/255.0f alpha:1.0f];
    [self.monthLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.selectMonthView.mas_top).offset(5);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(1);
    }];
    
    self.monthLab = [[UILabel alloc] init];
    self.monthLab.text = @"选择月份";
    self.monthLab.textColor = [UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f];
    self.monthLab.font = [UIFont systemFontOfSize:14.0f];
    [self.selectMonthView addSubview:self.monthLab];
    [self.monthLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.bottom.equalTo(self.monthLineView.mas_top).offset(-5);
    }];
    
    
}


@end
